﻿using LanguagePolish.Base;
using LanguagePolish.EntityModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LanguagePolish.ViewModels
{
    class AddLessonViewModel : BaseViewModel
    {
        public Lesson Lesson { get; private set; }

        public string Title { get; private set; }

        public bool HasErrors { get { return Lesson.HasErrors; } }

        public IEnumerable<Classroom> Classrooms
        {
            get { return LinksProvider.Model.EntityContext.Classrooms.ToList(); }
        }

        public IEnumerable<Teacher> Teachers
        {
            get { return LinksProvider.Model.EntityContext.Teachers.ToList(); }
        }

        public IEnumerable<Class> Classes
        {
            get { return LinksProvider.Model.EntityContext.Classes.ToList(); }
        }

        public IEnumerable<Subject> Subjects
        {
            get { return LinksProvider.Model.EntityContext.Subjects.ToList(); }
        }


        public AddLessonViewModel(Lesson lesson, bool isEdit)
        {
            Lesson = lesson;
            InitTitle(isEdit);
        }

        private void InitTitle(bool isEdit)
        {
            Title = isEdit ? "Edit Lesson" : "Add New Lesson";
            OnPropertyChanged("Title");
        }
    }
}
